package cn.singno.bob.web.editor;

import java.beans.PropertyEditorSupport;

public class BooleanEditor extends PropertyEditorSupport {

	private final static String TURE = "1";
	
	private final static String FALSE = "0";
	
	
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		switch (text) {
		case TURE:
			setValue(Boolean.TRUE);
			break;
		case FALSE:
			setValue(Boolean.FALSE);
			break;
		case "false":
			setValue(Boolean.FALSE);
			break;
		case "true":
			setValue(Boolean.TRUE);
			break;
		default:
			setValue(null);
			break;
		}
	}
	
	@Override
	public String getAsText() {
		return getValue().toString();
	}
}
